package daily.may0527;

import java.util.*;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class GetStreamTest {
    public static void main(String[] args) {
        //1.获取Collection集合的Stream流对象
        ArrayList<String> list = new ArrayList<>();
        Stream<String> listStream = list.stream();

        //2.Map集合的Stream流对象：不能直接获取，需要转换为Collection集合或其子集合
        HashMap<String, String> map = new HashMap<>();

        //keySet方法获取键，存储到一个Set集合中，然后获取Stream流对象
        Set<String> keySet = map.keySet();
        Stream<String> keyStream = keySet.stream();        
        //values方法获取值，存储到一个Collection集合中，然后获取Stream流对象
        Collection<String> valuesCollection = map.values();
        Stream<String> valueStream = valuesCollection.stream();
        //entrySet方法获取键值对，存储到一个Set集合中，然后获取Stream流对象
        Set<Map.Entry<String, String>> entriesSet = map.entrySet();
        Stream<Map.Entry<String, String>> entryStream = entriesSet.stream();

        //3.数组转换为Stream流
        String[] stringsArray = new String[]{"张三","李四","王五","赵六","田七"};
        int[] intArray = {333, 666, 999};
        //使用Stream接口的of方法获取Stream流对象，
        Stream<String> stringStream1 = Stream.of(stringsArray);
        Stream<int[]> intStream1 = Stream.of(intArray);
        //使用Arrays工具类的stream方法获取Stream流对象，
        Stream<String> stringStream2 = Arrays.stream(stringsArray);
        IntStream intStream2 = Arrays.stream(intArray);
    }
}
